package finbudgettable.client.ui.grid.cell.footer;

import java.math.BigDecimal;
import com.google.gwt.cell.client.AbstractSafeHtmlCell;
import com.google.gwt.core.client.GWT;
import com.google.gwt.safehtml.client.SafeHtmlTemplates;
import com.google.gwt.safehtml.shared.SafeHtml;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;

import finbudgettable.client.ui.grid.cell.currency.CurrencyCell;

public class FooterBigDecimalCell extends AbstractSafeHtmlCell<BigDecimal> {

	interface Template extends SafeHtmlTemplates {
        @Template("<div class=\"{0}\">{1}</div>")
        SafeHtml value(String className, SafeHtml value);

        @Template("<div class=\"{0}\">&nbsp;</div>")
        SafeHtml nullValue(String className);
    }
    private static final Template template = GWT.create(Template.class);

	public FooterBigDecimalCell() {
		super(BigDecimalRenderer.getInstance());
	}

	@Override
	protected void render(Context context, SafeHtml data, SafeHtmlBuilder sb) {
		if (data == null) {
			sb.append(template.nullValue(CurrencyCell.RESOURCES.style().bCurrencyCell__text()));
		} else {
			sb.append(template.value(CurrencyCell.RESOURCES.style().bCurrencyCell__text(), data));
		}
	}

}
